<div class="container">
  <h3>{{title}}</h3>

  <div class="form-group">
    <label for="">用户名</label>
    <input type="text" [(ngModel)]="iptUserName" class="form-control" placeholder="输入用户名">
  </div>
  <div class="form-group">
    <label for="">内容</label>
    <textarea  [(ngModel)]="iptContent"  class="form-control" rows="3"></textarea>
  </div>
  <button type="submit" (click)="add()" class="btn btn-primary">提交</button>

  <table class="table table-hover mt-3">
    <thead>
      <tr>
        <th>ID</th>
        <th>用户名</th>
        <th>内容</th>
        <th>操作</th>
      </tr>
    </thead>
    <tbody>
      <tr *ngFor="let item of list;let i=index;trackBy:item?.id">
        <td scope="row">{{item.id}}</td>
        <td>{{item.name}}</td>
        <td>{{item.content}}</td>
        <td>
          <button class="btn btn-danger" (click)="del(i)">删除</button>
          <button (click)="check(i)" type="button" class="btn btn-dark" data-toggle="modal" data-target="#checkContent">
            修改
          </button>
        </td>
      </tr>
    </tbody>
    <tfoot>
      <tr>
        <td colspan="4">
          <button class="btn" (click)="removeAll()">清空</button>
        </td>
      </tr>
    </tfoot>
  </table>

</div>



<div class="modal fade" id="checkContent" tabindex="-1" role="dialog" aria-labelledby="checkContentLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="checkContentLabel">修改{{checkContent?.name}}用户</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <div class="form-group">
          <textarea class="form-control" rows="3" [(ngModel)]="checkContent.content"></textarea>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
        <button type="button" class="btn btn-primary" (click)="save()"  data-dismiss="modal">保存</button>
      </div>
    </div>
  </div>
</div>